package cn.ylz.ylmall.account.dao.persist.repository.impl;

import cn.ylz.ylmall.account.dao.persist.mapper.RolePermissionMapper;
import cn.ylz.ylmall.account.dao.persist.repository.IRolePermissionRepository;
import cn.ylz.ylmall.account.pojo.entity.RolePermission;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public class RolePermissionRepositoryImpl implements IRolePermissionRepository {
    @Autowired
    private RolePermissionMapper rolePermissionMapper;
    @Override
    public int insertBatch(List<RolePermission> rolePermissionList) {
        int count = rolePermissionMapper.insertBatch(rolePermissionList);
        return count;
    }

    @Override
    public int deleteByRoleId(Long roleId) {
        QueryWrapper<RolePermission> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("role_id", roleId);
        return rolePermissionMapper.delete(queryWrapper);
    }

}
